Prev Next |
Sitecore query functions make it possible to perform Boolean operations with Items in query expressions and apply extra conditions to the query.
Function: contains(s1:string, s2:string):bool
Description: Indicates whether s1 contains substring s2. The comparison is case sensitive.
Query Example:
query:/sitecore/content/Home/Products/*[contains(@Text, 'Bargain')]
Returns child Items of the Products Item which contain 'Bargain' fragment in the Text field.
Function: startswith(s1:string,s2:string):bool
Description: Indicates whether s1 starts with substring s2. The comparison is case sensitive.
Query Example:
query:/sitecore/content/home//*[startswith(@@name, 'S')]
Returns child Items of the Home Item whose name starts with S.
Function: endswith(s1:string,s2:string):bool
Description: Indicates whether s1 ends with substring s2. The comparison is case sensitive.
Query Example:
query:/sitecore/content/home//*[endswith(@@name, 's')]
Returns child Items of the Home Item whose name ends with s.
Function: last():int
Description: Returns the index of the last Item in the list of children.
Query Example:
query:/sitecore/content/home/Products/*[last()]
Returns the index of the last child Item under the Products Item.
Function: not(condition:bool):bool
Description: Returns the parameter’s opposite value.
Query Example:
query:/sitecore/content/Home/Products/*[not(contains(@Text, 'Bargain'))]
Returns child Items of the Products Item whose text field doesn’t contain the string Bargain.
Function: position():int
Description: Returns the position of the context Item.
Query Example:
query:/sitecore/content/Home/Products/*[position() >= 2]
Returns child Items of the Products Item whose index is more than or equal to 2.
Prev Next